﻿using System;
using System.Threading;
using System.Windows.Forms;


namespace BookStoreGUI
{

    static class Program
    {

        private const string ApplicationName = "BookStore";

        /// <summary>
        /// Waiting time (in milliseconds) for the mutex, used to determine
        /// whether another instance of the application is already running.
        /// </summary>
        private const int WaitingTimeInMilliseconds = 50;


        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Mutex applicationMutex = new Mutex(false, ApplicationName);

            if (applicationMutex.WaitOne(WaitingTimeInMilliseconds, false) == false)
                Application.Run(new MultipleInstancesErrorForm());
            else
            {
                Application.Run(new MainForm());
                applicationMutex.ReleaseMutex();
            }
        }

    }

}
